<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>
    <!-- appear：页面加载时就触发动画效果 -->
    <!-- <transition name="hello" :appear="true"> -->
    <transition name="hello" appear>
        <h1 v-show="isShow">你好啊</h1>
    </transition>
  </div>
</template>

<script>
    export default {
        name: 'Test',
        data(){
            return {
                isShow: true
            }
        }
    }
</script>

<style scoped>
    h1{
        background-color: orange;
    }

    /* 
        如果<transition>有带name属性，这里的v要改成name 
        比如<transition>中的name属性是hello，这里就是hello-enter-active
    */
    /*.v-enter-active{*/
    .hello-enter-active{
        animation: chenjt 0.5s linear
    }

    /*.v-leave-active{*/
    .hello-leave-active{
        animation: chenjt 0.5s linear reverse;
    }

    @keyframes chenjt {
        from{
            transform: translateX(-100%)
        }
        to{
            transform: translateX(0px)
        }
    }

</style>
